/*
 * adlibr - Library for mobile AD mediation.
 * http://adlibr.com
 * Copyright (c) 2012 Mocoplex, Inc.  All rights reserved.
 * Licensed under the BSD open source license.
 */

/*
 * confirmed compatible with NaverAdPost SDK 1.0
 */

package com.crom.android.lottebaseball.ad;

import com.mocoplex.adlib.SubAdlibAdViewCore;
import com.nbpcorp.mobilead.sdk.MobileAdListener;
import com.nbpcorp.mobilead.sdk.MobileAdView;

import android.content.Context;
import android.util.AttributeSet;


/*
 AndroidManifest.xml ����� �댁���異���댁＜�몄�.
 
 <activity android:name="com.nbpcorp.mobilead.sdk.MobileAdBrowserActivity" />
 */

public class SubAdlibAdViewNaverAdPost extends SubAdlibAdViewCore  {
	
	protected MobileAdView ad;
	protected boolean bShowed = false;
    	
	public SubAdlibAdViewNaverAdPost(Context context) {
		this(context,null);
	}	
	
	public SubAdlibAdViewNaverAdPost(Context context, AttributeSet attrs) {
		super(context, attrs);
	
		// �ш린���ㅼ�踰����諛��諛�� key 瑜���������
		String naverAdPostKey = "mandroid_aad72d930d9e4883af60b6c3ba724244";		
		
		ad = new MobileAdView(context);
		ad.setChannelID(naverAdPostKey);
		ad.setTest(false);
				
		this.addView(ad);
		
		LayoutParams l = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
		ad.setLayoutParams(l);
		
		ad.start();
	}
	
	// �ㅼ�以�����������쇰� �몄��⑸���
	// �ㅼ�濡�愿��瑜�蹂댁�二쇨린 �������껌�⑸���	
	public void query()
	{		
		ad.setListener(new MobileAdListener() {

			@Override
			public void onReceive(int arg0) {
				
				if(arg0 == 0 || arg0 == 104)
				{
					// 愿�� ��� �깃났��寃쎌��� 寃��以�� 寃쎌�留���㈃��蹂댁����.
					gotAd();
				}
				else
				{
					failed();
				}
				
			}});
		
		ad.start();
	}
	
	// 愿��酉곕� ������ 寃쎌� �몄��⑸��� 
	public void clearAdView()
	{
		if(ad != null)
		{
			ad.destroy();
			ad = null;
		}

		super.clearAdView();
	}
	
	public void onResume()
	{
		super.onResume();
		
		if(ad != null)
		{
			ad.start();
		}
	}
	public void onPause()
	{
		super.onPause();
		
		if(ad != null)
		{
			ad.stop();
		}		
	}
}